volume: reset pool_id on failed volume create for zone-wide storage#13611
Open
nikolauseppinger wants to merge 1 commit into
Open
volume: reset pool_id on failed volume create for zone-wide storage#13611nikolauseppinger wants to merge 1 commit into
nikolauseppinger wants to merge 1 commit into
Conversation
When createVolumeAsync fails, createVolumeCallback resets the volume's pool_id only when volume.getPodId() != null. Zone-wide primary storage pools have no pod, so such a volume keeps a stale pool_id while it is reverted to Allocated. On the next create/attach, findStoragePool then returns no suitable pool because storagePoolCompatibleWithVolumePool rejects the volume (its state is not Ready), and the operation fails with "Unable to find suitable primary storage" even though the pool has plenty of capacity. Guard the reset on the field that is actually being cleared (getPoolId() != null) instead of getPodId(), so it also applies to zone-wide (and local) storage. The same guard is fixed in destroyAndReallocateManagedVolume. ensureVolumeIsExpungeReady is left unchanged as it legitimately clears pod_id. Regression from apache#10757.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
createVolumeAsyncfails,VolumeServiceImpl.createVolumeCallbackresets the volume'spool_idonly ifvolume.getPodId() != null. Zone-wide primary storage pools have no pod (pod_idisNULL), so on a failed create the volume is reverted toAllocatedbut keeps a stalepool_id.On the next create/attach,
VolumeOrchestrator.findStoragePoolthen returns no pool:StorageManagerImpl.storagePoolCompatibleWithVolumePoolrejects the volume because its state is notReady(it has apool_idbut isAllocated), so every candidate pool is filtered out. The operation fails with:even though the zone-wide pool is
Upand has plenty of free capacity. The only recovery is a manual DB fix (UPDATE volumes SET pool_id=NULL ...).Root cause: the guard added in #10757 keys on
getPodId(), which is only set for pod/cluster-scoped placement. The field actually being reset ispool_id, so the guard must key ongetPoolId().Fix: guard the reset on
getPoolId() != nullinstead ofgetPodId() != null, in bothcreateVolumeCallbackanddestroyAndReallocateManagedVolume.ensureVolumeIsExpungeReadyis intentionally left unchanged (it legitimately clearspod_id).Reproducible with encrypted volumes on a zone-wide SharedMountPoint pool: the first attach create fails (unrelated agent reason), leaving the volume stuck, after which all retries fail at
findStoragePool.Types of changes
Bug Severity
How Has This Been Tested?
On CloudStack 4.22.1.0 with a single zone-wide
SharedMountPointprimary storage (KVM):Allocatedwithpool_idstill set; every subsequent attach fails withUnable to find suitable primary storage.pool_idis reset toNULL, the volume returns to a cleanAllocatedstate, and the next attach picks the pool normally (verified: no manual DB intervention needed).